package hu.mapro.gwtui.client.data;

import java.util.List;

import com.google.common.collect.Lists;
import com.google.web.bindery.requestfactory.shared.RequestContext;

public class SortUtils {

	public static List<SortFieldProxy> createSortFields(
			List<SortField> sortInfo,
			final RequestContext rc
	) {
		final List<SortFieldProxy> fields = Lists.newArrayList();

		for (final SortField si : sortInfo) {
			si.createExpression(new SortBuilder() {
				@Override
				public void namedField(String name) {
					NamedSortFieldProxy f = rc.create(NamedSortFieldProxy.class);
					f.setAscending(si.getAscending());
					f.setName(name);
					fields.add(f);
				}
			});
		}
		
		return fields;
	}
	
}
